package cn.yunhe.interceptor;

import cn.yunhe.action.SleepAction;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import lombok.Data;

import java.util.Date;

@Data
public class MyInterceptor extends AbstractInterceptor {
    private int sleep;
    private String result;
    @Override
    public String intercept(ActionInvocation actionInvocation) throws Exception {
        System.out.println("开始拦截:"+new Date().toLocaleString());
        SleepAction action = (SleepAction) actionInvocation.getAction();
        action.setSleep(sleep);
        result=actionInvocation.invoke();
        System.out.println("结束了:"+new Date().toLocaleString());
        return result;
    }
}
